//===============================================================================
//	CAddNeighbour
//	增加附近用户
//===============================================================================

#include "CAddNeighbour.h"
#include "ManagerHelper.h"

#include "Player.h"

//-------------------------------------------------------------------------------
CAddNeighbour::CAddNeighbour(uint32_t uid, uint32_t pn)
	: BaseMessage(uid, pn)
{
	_safe_guard_begin;
	_safe_guard_end;
}

//-------------------------------------------------------------------------------
CAddNeighbour::~CAddNeighbour(void)
{
}

void CAddNeighbour::SetAddNeighbourList(Map* scene, std::vector<uint32_t>* list)
{
	_safe_guard_begin;

	Json::Value _arrayObj;
	Json::Value _info;

	//LOG_DEBUG("default","CAddNeighbour::SetAddNeighbourList count : %d\n", list->size());

// 	_arrayObj.clear();
// 	for (auto it : *list)
// 	{
// 		MapElement* _me = scene->GetMapElementByKey(it);
// 		if (!_me)
// 		{
// 			continue;
// 		}
// 		_safe_check(_me);
// 
// 		if (nullptr != _me)
// 		{
// 			_info.clear();
// 			_info["si"] = _me->GetSceneId();
// 			//_info["ky"] = _me->GetGameServerKey();//GetKey();
// 			_info["px"] = _me->GetMapPosX();
// 			_info["pz"] = _me->GetMapPosZ();
// 			_info["py"] = _me->GetPosY();
// 			_info["td"] = _me->GetTypeId();
// 
// 			int32_t _gt = int32_t(_me->GetObjectType());
// 			int32_t _tp = _gt;
// 			if (_tp > GOT_PLAYER)
// 			{
// 				_tp -= GOT_PLAYER;
// 			}
// 			_info["tp"] = _tp;
// 
// 			if (GOT_PLAYER == _gt)
// 			{
// 				Player* _to_player = dynamic_cast<Player*>(_me);
// 				_safe_check(_to_player);
// 
// 				//todo:jin
// 				//_info["ky"] = _me->GetGameServerKey();
// 				_info[ "ky" ]=_me->GetKey();
// 				//std::cout<< "key: " << _me->GetKey() << " serverkey:" <<_me->GetGameServerKey()<<std::endl;
// 
// 				_info["ai"] = _to_player->GetAccount();
// 				_info["pi"] = _to_player->GetPlayerId();
// 				_info["ri"] = _to_player->GetHeroId();
// 				_info["tl"] = 0;// _to_player->GetWearingTitleId();
// 				_info["nm"] = std::string(_to_player->GetName());
// 				_info["mountsState"] = std::to_string(_to_player->GetMountsState());
// 
// 				_info["unId"] = _to_player->GetUnionId();
// 				_info["unNm"] = _to_player->GetUnionName();
// 				_info["pt"] = _to_player->GetPetId();
// 				_info["mt"] = _to_player->GetMountsId();
// 				_info["skinid"] = _to_player->GetHeroSkinId();
// 				_info["areaId"] = _to_player->GetArea();
// 			}
// 			else
// 			{
// 				_info["ky"] = _me->GetKey();
// 
// 				_info["ai"] = 0;
// 				_info["pi"] = 0;
// 				_info["ri"] = 0;
// 				_info["nm"] = "";
// 			}
// 
// 			if (GOT_MONSTER == _gt || GOT_RAND_MONSTER == _gt)
// 			{
// 				Monster* _to_player = dynamic_cast<Monster*>(_me);
// 				_safe_check(_to_player);
// 
// 				_info["rc"] = _to_player->GetResetCount();
// 				_info["hp"] = _to_player->GetHp();
// 			}
// 			else
// 			{
// 				_info["rc"] = 0;
// 			}
// 
// 			_arrayObj.append(_info);
// 		}
// 	}
// 	
// 
// 	m_jv.clear();
// 	m_jv["al"] = _arrayObj;
	
	_safe_guard_end;
}

//-------------------------------------------------------------------------------
